---
title: Infrastructure
description: Configure queue behavior, retries, and timeouts for Event Steps
---

Infrastructure settings let you control how Event Steps handle queues, retries, and timeouts. Motia provides sensible defaults, so you only configure what you need.

## How It Works

Add `infrastructure` to your Event Step config:

<Tabs items={['TypeScript', 'Python', 'JavaScript']}>
<Tab value='TypeScript'>

```typescript
export const config: EventConfig = {
  name: 'SendEmail',
  type: 'event',
  subscribes: ['email.requested'],
  infrastructure: {
    handler: { timeout: 10 },
    queue: { maxRetries: 5, visibilityTimeout: 60 }
  }
}
```

</Tab>
<Tab value='Python'>

```python
config = {
    "name": "SendEmail",
    "type": "event",
    "subscribes": ["email.requested"],
    "infrastructure": {
        "handler": {"timeout": 10},
        "queue": {"maxRetries": 5, "visibilityTimeout": 60}
    }
}
```

</Tab>
<Tab value='JavaScript'>

```javascript
const config = {
  name: 'SendEmail',
  type: 'event',
  subscribes: ['email.requested'],
  infrastructure: {
    handler: { timeout: 10 },
    queue: { maxRetries: 5, visibilityTimeout: 60 }
  }
}
```

</Tab>
</Tabs>

---

## Configuration Options

### Handler Settings

| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `timeout` | `number` | 30 | Handler timeout in seconds |

### Queue Settings

| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `type` | `string` | `standard` | Queue type: `standard` or `fifo` |
| `maxRetries` | `number` | 3 | Number of retry attempts on failure |
| `visibilityTimeout` | `number` | 900 | Seconds before message becomes visible again |
| `delaySeconds` | `number` | 0 | Delay before processing (0-900 seconds) |

---

## FIFO Queues

FIFO queues guarantee exactly-once processing and maintain message order within a group.

<Tabs items={['TypeScript', 'Python', 'JavaScript']}>
<Tab value='TypeScript'>

```typescript
export const config: EventConfig = {
  name: 'ProcessOrder',
  type: 'event',
  subscribes: ['order.created'],
  infrastructure: {
    queue: {
      type: 'fifo'
    }
  }
}
```

</Tab>
<Tab value='Python'>

```python
config = {
    "name": "ProcessOrder",
    "type": "event",
    "subscribes": ["order.created"],
    "infrastructure": {
        "queue": {
            "type": "fifo"
        }
    }
}
```

</Tab>
<Tab value='JavaScript'>

```javascript
const config = {
  name: 'ProcessOrder',
  type: 'event',
  subscribes: ['order.created'],
  infrastructure: {
    queue: {
      type: 'fifo'
    }
  }
}
```

</Tab>
</Tabs>

### Message Group ID

When emitting to FIFO queues, pass a `messageGroupId`:

<Tabs items={['TypeScript', 'Python', 'JavaScript']}>
<Tab value='TypeScript'>

```typescript
export const handler: Handlers['CreateOrder'] = async (req, { emit }) => {
  const { orderId, customerId } = req.body
  
  await emit({
    topic: 'order.created',
    data: { orderId, customerId },
    messageGroupId: customerId  // Required for FIFO
  })
}
```

</Tab>
<Tab value='Python'>

```python
async def handler(req, ctx):
    order_id = req.body["orderId"]
    customer_id = req.body["customerId"]
    
    await ctx.emit({
        "topic": "order.created",
        "data": {"orderId": order_id, "customerId": customer_id},
        "messageGroupId": customer_id  # Required for FIFO
    })
```

</Tab>
<Tab value='JavaScript'>

```javascript
const handler = async (req, { emit }) => {
  const { orderId, customerId } = req.body
  
  await emit({
    topic: 'order.created',
    data: { orderId, customerId },
    messageGroupId: customerId  // Required for FIFO
  })
}
```

</Tab>
</Tabs>

The `messageGroupId` ensures events are processed in order within that group.

---

## Default Values

If you don't specify infrastructure settings, Motia uses these defaults:

```typescript
{
  handler: {
    timeout: 30
  },
  queue: {
    type: 'standard',
    maxRetries: 3,
    visibilityTimeout: 900,
    delaySeconds: 0
  }
}
```

---

